package com.blb.edufileservice.controller;

import com.blb.edufileservice.service.IPageService;
import com.learn.eduapi.entity.Course;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Slf4j
@Controller
public class PageController {

    @Autowired
    private IPageService pageService;

    @GetMapping("course/{id}.html")
    public String toCoursePage(@PathVariable("id")Integer id, Model model){
        Course course = pageService.createCoursePage(id);
        model.addAttribute("course",course);
        log.info("toCoursePage {}", course);
        return "course";
    }
}
